package com.vess.ratingweb;

import java.util.ArrayList;

import android.content.ContentValues;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;

public class Attributes {
	private static int mResID;
	private static ArrayList<String> mWelcomeContent;
	private static Context context;
	
	public static Drawable mLogo;
	public static DBAdapter mDB;
	public static String mLogoPath = "";
	public static String mWelCoText = "";
	public static String mWelCoImg = "";
	
	static void init(Context ctx) {
		context = ctx;
		mResID = context.getResources().getIdentifier("logo", "drawable", context.getPackageName());
		mLogo = context.getResources().getDrawable(mResID);
		
		// Database
		mDB = new DBAdapter(context);
		mDB.open();
		mWelcomeContent = mDB.selectTable("WELCOME");
		extractData();
	}
	
	static void setLogo(String path){
		mLogo = Drawable.createFromPath(path);
	}
	
	static void setInfoSettings(String logo_path, String txtSample, String imgSamplePath) {
		ContentValues content = new ContentValues();
		
		content.put(DBAdapter.IMG_PATH, logo_path);
		content.put(DBAdapter.WELCOME_TEXT, txtSample);
		content.put(DBAdapter.WELCOME_IMG, imgSamplePath);
		
		mDB.updateData("WELCOME", content);
		mWelcomeContent = mDB.selectTable("WELCOME");
		extractData();
	}
	
	static void extractData(){
		Log.i("extract", mWelcomeContent.toString());
		mLogoPath = mWelcomeContent.get(0);
		mWelCoText = mWelcomeContent.get(1);
		mWelCoImg = mWelcomeContent.get(2);
	}
}
